package com.example.config.ImageMap;


import com.example.config.Utility.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

@RestController
@RequestMapping("common")
public class common {


    @PostMapping("/gets")
    public Result<String> getFile(MultipartFile file) throws IOException {

        System.out.println(file);

        String originalFilename = file.getOriginalFilename();
        String substring = originalFilename.substring(originalFilename.lastIndexOf("."));
        System.out.println(substring);
        //转存文件
        file.transferTo(new File("D:\\图片\\测试\\KK.jpg"));
        return Result.succeed(substring);
    }

}


